package com.santu.edu.supporter.biz.category.controller;

import com.santu.edu.supporter.biz.category.pojo.dto.GoodCategoryDTO;
import com.santu.edu.supporter.biz.category.pojo.params.GoodCategoryAddParam;
import com.santu.edu.supporter.biz.category.pojo.params.GoodCategoryUpdateParam;
import com.santu.edu.supporter.biz.category.service.GoodCategoryService;
import com.santu.edu.supporter.biz.user.pojo.dto.UserAddressDTO;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * @author luoyaoqi
 * @createTime 2024/3/12
 * @description
 */
@RestController
@Validated
@RequiredArgsConstructor
@RequestMapping("category")
public class GoodCategoryController {

    private final GoodCategoryService goodCategoryService;


    @PostMapping("add")
    public Boolean addUserAddress(@RequestBody @Valid GoodCategoryAddParam addParam) {
        return goodCategoryService.addGoodCategory(addParam);
    }

    @PostMapping("update")
    public Boolean updateUserAddress(@RequestBody @Valid GoodCategoryUpdateParam updateParam) {
        return goodCategoryService.updateGoodCategory(updateParam);
    }

    @PostMapping("remove")
    public Boolean removeUserAddress(@NotBlank(message = "addressId不能为空") String categoryId) {
        return goodCategoryService.removeGoodCategory(categoryId);
    }


    @GetMapping("get/address/by/userId")
    public List<GoodCategoryDTO> getUserAddressList() {
        return goodCategoryService.getGoodCategoryList();
    }

}
